<?php

function follow_user() {
    var_dump($_POST);
}
add_action( 'wp_ajax_follow_user', 'follow_user' );


function cb_show_follow_action()
{
        ?>
        <script>
        var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';
        jQuery(document).ready(function () {
            jQuery("#followbtn").click(function(e){
                e.preventDefault();
                jQuery.post(
                ajaxurl, 
                {
                    'action': 'follow_user',
                    'data':   '{user: 1, follow:2}'
                }, 
                function(response){
                    alert('The server responded: ' + response);
                }
                );
            });
           }); 

        </script>
        <a id="followbtn">Theo đuôi</a>
    <?php
}
add_action('show_follow', 'cb_show_follow_action');

function show_follow()
{
    do_action('show_follow');
}



?>
